import request from '#/utils/request';
import { replaceGetMethodParam } from '#/utils/utils';

export async function getRequestByFormId(url, params = {}, method = 'POST', otherConfig = {}) {
  if (method === 'get' || method === 'GET') return request(replaceGetMethodParam(url, params));
  return request(url, {
    method,
    data: params,
    ...otherConfig,
  });
}

export async function classAttribute(params) {
  return request(`/eam-ledger/classAttribute/findClassAtt`, {
    method: 'POST',
    data: params,
  });
}

export async function tableLayout(params) {
  return request('/table-layout/layout/id', {
    method: 'POST',
    data: params,
  });
}

export async function downFile(params) {
  let url = params.match('http') ? params : `/annex/annex/downLoadFile/${params}`;
  return request(url, {
    responseType: 'blob',
    getResponse: true,
  });
}
